package com.example.openapi.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * 勤策OpenAPI配置类
 *
 * @author MCP Service
 * @version 1.0.0
 */
@Slf4j
@Configuration
public class WaiqinApiConfig {

    @Autowired
    private WaiqinApiProperties properties;

    @PostConstruct
    public void init() {
        log.info("========================================");
        log.info("初始化勤策OpenAPI配置");
        log.info("API地址: {}", properties.getApiUrl());
        log.info("OpenID: {}", maskString(properties.getOpenid()));
        log.info("连接超时: {}ms", properties.getConnectTimeout());
        log.info("读取超时: {}ms", properties.getReadTimeout());
        log.info("========================================");
    }

    /**
     * 隐藏敏感信息
     */
    private String maskString(String str) {
        if (str == null || str.length() < 8) {
            return "****";
        }
        return str.substring(0, 4) + "****" + str.substring(str.length() - 4);
    }
}
